-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mic_privacy: initial implementation #9788
base: main
Are you sure you want to change the base?
Conversation
IPC4_UAOL_CAPS_HW_CFG = 10 | ||
IPC4_UAOL_CAPS_HW_CFG = 10, | ||
/* Mic privacy capabilities */ | ||
IPC4_PRIVACY_CAPS_HW_CFG = 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would re-name these to be more specific to:
IPC4_INTEL_MIC_PRIVACY_CAPS_HW_CFG (and IPC4_INTEL_UAOL_CAPS_HW_CFG).
it looks to me that we are passing the raw content of the DfMICPVCP register, which is pretty much Intel specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to IPC4_INTEL_MIC_PRIVACY_CAPS_HW_CFG. I don't think other vendors will have MICPVCP register in their SoC.
return mic_privacy_api->get_dma_data_zeroing_link_select(); | ||
} | ||
//hardcoded for FW_MANAGED | ||
return 0xFFFFFFFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~0
return 0xFFFFFFFF; | ||
} | ||
|
||
struct mic_privacy_settings fill_mic_priv_settings(uint32_t mic_disable_status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think supplying a structure to be filled as a parameter is preferred over returning one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbukowsk can you confirm a high level overview of how it works when FW managed. i.e. I assume FW will send an IPC to SW when the mute is enabled/disabled ? What about Mic state at FW boot ?
#include <ipc4/base-config.h> | ||
#include "../audio/copier/copier_gain.h" | ||
|
||
#define ADSP_RTC_FREQUENCY 32768 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in Zephyr as its HW specific.
int mic_privacy_manager_init(void); | ||
|
||
int mic_privacy_manager_get_policy(void); | ||
|
||
uint32_t mic_privacy_get_policy_register(void); | ||
|
||
void enable_fw_managed_irq(bool enable_irq); | ||
|
||
void enable_dmic_irq(bool enable_irq); | ||
|
||
void handle_dmic_interrupt(void * const self, int a, int b); | ||
|
||
void handle_fw_managed_interrupt(void * const dev); | ||
|
||
void propagate_privacy_settings(struct mic_privacy_settings *mic_privacy_settings); | ||
|
||
uint32_t get_dma_zeroing_wait_time(void); | ||
|
||
uint32_t get_privacy_mask(void); | ||
|
||
struct mic_privacy_settings fill_mic_priv_settings(uint32_t mic_disable_status); | ||
|
||
void set_gtw_mic_state(struct mic_privacy_data *mic_priv_data, uint32_t mic_disable_status); | ||
|
||
void update_gtw_mic_state(struct mic_privacy_data *mic_priv_data, uint32_t hw_mic_disable_status); | ||
|
||
void mic_privacy_process(struct comp_dev *dev, struct mic_privacy_data *mic_priv, struct comp_buffer *buffer, uint32_t copy_samples); | ||
|
||
void mic_priv_gain_input(uint8_t *buff, uint32_t buff_size, uint32_t mic_priv_state, | ||
const struct ipc4_audio_format *in_fmt); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are all for client usage of Mic privacy then they should all share the same mic_privacy_
prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No bugs from me (the others already found the serious stuff), but couple of suggestions more.
70c6211
to
37336ba
Compare
@mbukowsk can you check CI, several failures. Thanks ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbukowsk, the privacy_capabilities is configured to the wrong struct, that is going to case the host quite a bit of issues as it will not find it in hw_config and there will be two entries with the same ID in fw_config.
@@ -51,6 +54,10 @@ SOF_DEFINE_REG_UUID(copier); | |||
|
|||
DECLARE_TR_CTX(copier_comp_tr, SOF_UUID(copier_uuid), LOG_LEVEL_INFO); | |||
|
|||
#if CONFIG_MICROPHONE_PRIVACY | |||
static int mic_privacy_configure(struct comp_dev *dev, struct copier_data *cd); | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you add the mic_privacy_configure() so that forward declaration is not needed?
Plus:
#else
static inline int mic_privacy_configure(struct comp_dev *dev, struct copier_data *cd) { return 0 }
#endif /* CONFIG_MICROPHONE_PRIVACY */
and you can save on the ifdefs in code
@@ -131,6 +138,15 @@ static int copier_init(struct processing_module *mod) | |||
comp_err(dev, "unable to create host"); | |||
goto error; | |||
} | |||
#if CONFIG_MICROPHONE_PRIVACY | |||
if (cd->direction == SOF_IPC_STREAM_CAPTURE && node_id.f.dma_type == ipc4_hda_host_output_class) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
123 chars long..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still 123 long.
@@ -27,7 +30,7 @@ int copier_gain_set_params(struct comp_dev *dev, struct copier_gain_params *gain | |||
/* Set basic gain parameters */ | |||
copier_gain_set_basic_params(dev, gain_params, ipc4_cfg); | |||
|
|||
switch (dd->dai->type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did this compiled before this patch?
I cannot see dd
anywhere in the change,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and if there were dd
to begin with, then why we don't we take the pointers out from it locally?
src/audio/copier/copier_gain.h
Outdated
* @return 0 on success, negative error code on failure. | ||
*/ | ||
int copier_gain_set_params(struct comp_dev *dev, struct copier_gain_params *gain_params, uint32_t fade_period); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no dd
was here either
struct ipc4_copier_module_cfg *copier_cfg = cd->dd[0]->dai_spec_config; | ||
const int channels = copier_cfg->base.audio_fmt.channels_count; | ||
|
||
ret = copier_set_gain(dev, cd->dd[0]->gain_data, gain_data, channels); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two gain_data is a bit confusing here.
} | ||
} | ||
|
||
void update_gtw_mic_state(struct mic_privacy_data *mic_priv_data, uint32_t hw_mic_disable_status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, but I cannot see that this function is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still not called?
@ujfalusi ok that's a blocker for kernel. Can you reply with what this should look like for kernel so @mbukowsk can copy. |
No, this is a blocker for this PR. The firmware places the IPC4_PRIVACY_CAPS_HW_CFG (as is a hardware configuration tuple with ID 11) into the FW_CFG (as is firmware configuration). The ID 11 is IPC4_MAX_ASTATE_COUNT_FW_CFG in firmware config. These are different configurations, one is queried with SOF_IPC4_FW_PARAM_FW_CONFIG (basefw param 6), the other is SOF_IPC4_FW_PARAM_HW_CONFIG_GET (basefw param 7). The IPC4_PRIVACY_CAPS_HW_CFG must be placed to the hardware config data in The corresponding kernel patch is thesofproject/linux@7f00cf9 |
src/audio/copier/copier_gain.c
Outdated
int ret; | ||
|
||
/* Set basic gain parameters */ | ||
copier_gain_set_basic_params(dev, dd, ipc4_cfg); | ||
copier_gain_set_basic_params(dev, gain_params, ipc4_cfg); | ||
|
||
switch (dd->dai->type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, so at this patch this is not going to compile. dd
is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for dd it looks like part of this change is placed in the next commit, I will move it to the first one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks that way, I'll wait for the update with the fix.
Change type of arguments for gain params setting functions. DAI data struct is replaced by gain_params. Components other than DAI can also use copier gain feature (eg. microphone privacy) Signed-off-by: Michal Bukowski <[email protected]>
Audio privacy feature allows end user to directly control if user space applications receive actual data from input devices (microphones). The control is bypassing application level settings or operating system controls (like audio endpoint volume). Signed-off-by: Michal Bukowski <[email protected]>
Added empty implementation which always returns success Signed-off-by: Michal Bukowski <[email protected]>
…ANGE SW sends this IPC when microphone privacy state is changed for HW_MANAGED mode and SNDW interface. Signed-off-by: Michal Bukowski <[email protected]>
37336ba
to
e5a1ec1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abonislawski , there are also valid checkpatch finds.
src/audio/copier/copier_gain.c
Outdated
int ret; | ||
|
||
/* Set basic gain parameters */ | ||
copier_gain_set_basic_params(dev, dd, ipc4_cfg); | ||
copier_gain_set_basic_params(dev, gain_params, ipc4_cfg); | ||
|
||
switch (dd->dai->type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks that way, I'll wait for the update with the fix.
Audio privacy feature allows end user to directly control if user space | ||
applications receive actual data from input devices (microphones). | ||
The control is bypassing application level settings or operating system | ||
controls (like audio endpoint volume). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really Intel specific implementation of a microphone privacy, I think this has to be mentioned
@@ -25,6 +25,7 @@ | |||
#include <sof/debug/telemetry/performance_monitor.h> | |||
#include <sof/debug/telemetry/telemetry.h> | |||
#include <sof/debug/telemetry/performance_monitor.h> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spurious change
IPC4_UAOL_CAPS_HW_CFG = 10 | ||
IPC4_UAOL_CAPS_HW_CFG = 10, | ||
/* Mic privacy capabilities */ | ||
IPC4_PRIVACY_CAPS_HW_CFG = 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to IPC4_INTEL_MIC_PRIVACY_CAPS_HW_CFG. I don't think other vendors will have MICPVCP register in their SoC.
|
||
uint32_t get_dma_zeroing_wait_time(void); | ||
|
||
uint32_t get_privacy_mask(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for these blank lines.
@@ -362,12 +363,12 @@ dai_dma_cb(struct dai_data *dd, struct comp_dev *dev, uint32_t bytes, | |||
ret = -EINVAL; | |||
continue; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the blank line was fine.
sink, converter[j], | ||
bytes, dd->chmap); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for blank line
|
||
LOG_MODULE_REGISTER(LOG_DOMAIN); | ||
|
||
int mic_privacy_manager_init(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is Intel specific, can we emphasize it with file name and external API names?
mic_priv_data->mic_privacy_state = MIC_PRIV_MUTED; | ||
} else { | ||
mic_priv_data->mic_privacy_state = MIC_PRIV_UNMUTED; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what is the coding style in SOF now-days, but this patch uses two style when there is a single instruction in the if/else
Zephyr demands curly brackets always, like this. We used to be following the kernel's with no need for them.
} | ||
} | ||
|
||
void update_gtw_mic_state(struct mic_privacy_data *mic_priv_data, uint32_t hw_mic_disable_status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still not called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abonislawski some high level questions.
- In HW managed - FW gets IRQ from HW and mutes. Does it send IPC to SW to inform ?
- In FW managed mode - How does FW know when to mute - is it relying on SW to send an IPC ?
Audio privacy feature allows end user to directly
control if user space applications receive actual
data from input devices (microphones). The control
is bypassing application level settings or operating
system controls (like audio endpoint volume).